﻿using UnityEngine;
using System.Collections;

namespace Lost{
	/// <summary>
	/// 锁
	/// </summary>
	public class Lock : MonoBehaviour {
		protected bool isLock = true;
		[SerializeField] Machine mac;

		///尝试开门
		public bool TryUnlock(LockKey key){
			if (key.CanUsed) {
				isLock = !CheckKey (key);
				if (isLock == false) {
					mac.StartMachine ();
					Destroy (this);
				}
			}
			return !isLock;
		}

		protected virtual bool CheckKey(LockKey key){
			return true;
		}
	}
}
